import {axios} from '@/utils/request'

// api接口列表
const api = {
    list: '/coupon/list',
    detail: '/coupon/{id}',
    add: '/coupon',
    disable: '/coupon/{id}/disable',
    receive: '/user-coupon/received'
}

// 列表记录
export function list(params) {
    return axios({
        url: api.list,
        method: 'get',
        params
    })
}

// 详情记录
export function detail(id) {
    return axios({
        url: api.detail.replace('{id}', id),
        method: 'get'
    })
}

/**
 * 新增记录
 * @param {*} data
 */
export function add(data) {
    return axios({
        url: api.add,
        method: 'post',
        data
    })
}

/**
 * 编辑记录
 * @param {*} id
 */
export function disabled(id) {
    return axios({
        url: api.disable.replace('{id}', id),
        method: 'put'
    })
}

// 领取记录
export function receive(params) {
    return axios({
        url: api.receive,
        method: 'get',
        params
    })
}